<template>
  <div>home</div>
</template>

<script>
import axios from 'axios'
export default {
  created() {
    // axios.post("/admin/admin/login",{
    //   adminname:'admin',
    //   password:'123456'
    // }).then((res)=>{
    //    console.log(res)
    // })
    //eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbm5hbWUiOiJhZG1pbiIsImlhdCI6MTY3MjE5NDAzNSwiZXhwIjoxNjcyMjIyODM1fQ.jSRlyjckJLvniI1wYc8RO28WKsmMBkul3_tfscQUqoM

   //每一次发请求都会自动执行这个函数
    axios.interceptors.request.use((config)=>{
      console.log("每次发请求都会执行",config)
      // config.url="/admin"+config.url
      config.headers.token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbm5hbWUiOiJhZG1pbiIsImlhdCI6MTY3MjE5NDYzMiwiZXhwIjoxNjcyMjIzNDMyfQ.UKrBrEuEC3P9aMldNIZAwB1iYNUfrz6ugDCVgp6Me1k"
      return config;
    })
    //每一次服务器端数据返回都会执行这个函数
    axios.interceptors.response.use((res)=>{
      return res.data
    })
    axios.defaults.baseURL="/admin"
    axios.post("/pro/searchPro", {
      category: '手机',
      search: 'Apple'

    }
    ).then((res) => {
        console.log(res.data)
    })

      axios.get("/admin/detail?adminname=lulu").then((res)=>{
        console.log(res.data)
      })
  }
}

</script>
<style scoped>

</style>